﻿using System;
using System.Linq;

namespace _131_将分组后的序列重新排序_LINQ语法
{
    class Program
    {
        static void Main(string[] args)
        {

            //初始化一个数组
            string[] arrsrc =
            {
                "at","act","market","fable","also","alt","bee","back","book","build","fase","full","fish","food","find","meet","make","moo","muklek"
            };


            //将以上数组中的单词按首字母进行分组，并对组内的单词重新排序
            var 查询 = from s in arrsrc
                     group s by s[0].ToString().ToUpper() into g
                     orderby g.Key
                     let nq = (from w in g
                               orderby w
                               select w)
                     select (Key: g.Key, Items: nq);

            foreach (var t in 查询)
            {
                Console.WriteLine("大字母"+t.Key);
                foreach (var sub in t.Items)
                {
                    Console.WriteLine(" {0}", sub);
                }
            }

        }
    }
}
